﻿@using TjZheng.Domain.DataEntity;
@{
    Layout = null;
    ControlInfo objControlInfo = this.ViewData["ControlInfo"] as ControlInfo;
    if (objControlInfo != null && !objControlInfo.IsEditShow)
    {
        return;
    }
    object value = this.ViewData["Value"];
    Dictionary<string, object> htmlAttributes = new Dictionary<string, object>();
    if (objControlInfo.Style.IsNoNull())
    {
        htmlAttributes["style"] = objControlInfo.Style;
    }
    List<string> validTypeList = new List<string>();
    if (objControlInfo.Length > 0 && objControlInfo.DataType.Contains("varchar"))
    {
        validTypeList.Add(ValidType.Length(objControlInfo.Length));
    }
    if (objControlInfo.Regex.IsNoNull())
    {
        validTypeList.Add(ValidType.Regex(objControlInfo.Regex));
    }
    List<string> selectControls = new List<string> { "ComboBox", "CheckBox", "CheckBoxList", "RadioButtonList" };
    List<SelectListItem> objSelectListItems = null;
    if (selectControls.Contains(objControlInfo.ControlType))
    {
        if (objControlInfo.Definition.IsNoNull())
        {
            objSelectListItems = new List<SelectListItem>();
            string[] array;
            foreach (string s1 in objControlInfo.Definition.Split(','))
            {
                array = s1.Split('|');
                objSelectListItems.Add(new SelectListItem { Value = array[0], Text = array[1] });
            }
        }
    }
}
@inherits CMSWebViewPage<object>
<tr>
    <td>
        @if (objControlInfo.IsRequired)
        {
            <span class="txtNoNull">*</span>
        }
        @objControlInfo.DisplayName:
    </td>
    <td>
        @switch (objControlInfo.ControlType)
        {
            case "StringBox":
                @Html.StringBox("objProvide." + objControlInfo.Name, value, objControlInfo.IsRequired, objControlInfo.Message, htmlAttributes, validTypeList.ToArray())
                break;
            case "NumberBox":
            @Html.NumberBox("objProvide." + objControlInfo.Name, value, htmlAttributes, 0, 0, 0, validTypeList.ToArray())
                break;
            case "ComboBox":
            @Html.ComboBox("objProvide." + objControlInfo.Name, value, objControlInfo.IsRequired, objControlInfo.Message, objSelectListItems, htmlAttributes, null)
                break;
            case "CheckBox":
                if (objSelectListItems != null && objSelectListItems.Count >= 2)
                {
                    @Html.CheckBox("objProvide." + objControlInfo.Name, value, objSelectListItems.First().Value, objSelectListItems.Last().Value, htmlAttributes)
                }
                else
                {
                    @Html.CheckBox("objProvide." + objControlInfo.Name, value, 1, 0, htmlAttributes)
                }
                break;
            case "CheckBoxList":
            @Html.CheckBoxList("objProvide." + objControlInfo.Name, value, objControlInfo.IsRequired, objSelectListItems, htmlAttributes)
                break;
            case "RadioButtonList":
            @Html.RadioButtonList("objProvide." + objControlInfo.Name, value, objControlInfo.IsRequired, objSelectListItems, htmlAttributes)
                break;
            case "DateTimeBox":
            @Html.DateTimeBox("objProvide." + objControlInfo.Name, value, htmlAttributes, validTypeList.ToArray())
                break;
            case "UpLoadImage":
            @Html.UpLoadImage(4, "objProvide." + objControlInfo.Name, value.ToString())
                break;
            case "UpLoadImages":
            @Html.UpLoadImages(4, "objProvide." + objControlInfo.Name, value.ToString())
                break;
            case "UpLoadNativeImage":
            @Html.UpLoadNativeImage(4, "objProvide." + objControlInfo.Name, value.ToString())
                break;
            case "TextArea":
            @Html.TextArea("objProvide." + objControlInfo.Name, value.ToString(), 5, 100, htmlAttributes)
                break;
            case "Ueditor":
            @Html.Ueditor(4, 5, "objProvide." + objControlInfo.Name, value.ToString(), htmlAttributes)
                break;
        }
    </td>


</tr>